/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view;

import controller.ChangePasswordController;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import model.Base;
import net.miginfocom.swing.MigLayout;

/**
 *
 * @author Pierre-Antoine
 */
public class ChangePasswordWindow extends JDialog{
	
	//<editor-fold defaultstate="collapsed" desc="noms des composants">
	public static final String BTN_CANCEL = "btn_cancel";
	public static final String BTN_OK = "btn_ok";
	//</editor-fold>

    private JLabel lblInfo = new JLabel("changement du mot de passe");
    private JButton btnCancel = new JButton("Annuler");
    private JButton btnChange = new JButton("Modifier");
    private JLabel lblOldPassword = new JLabel("Ancien mot de passe");
    private JLabel lblNewPassword = new JLabel("nouveau mot de passe");
    private JLabel lblConfirmNewPassword = new JLabel("confirmer le nouveau mot de passe");
    private JTextField txtOldPassword = new JPasswordField(11);
    private JTextField txtNewPassword = new JPasswordField(11);
    private JTextField txtConfirmNewPassword = new JPasswordField(11);
	private ChangePasswordController controller;

    public ChangePasswordWindow(Base model){

		this.controller = new ChangePasswordController(model, this);
		
		// Noms des composants
		this.btnCancel.setName(BTN_CANCEL);
		this.btnChange.setName(BTN_OK);
		
		this.setLayout(new MigLayout());

		this.add(lblInfo,"span");
		this.add(lblOldPassword);
		this.add(txtOldPassword,"wrap");
		this.add(lblNewPassword);
		this.add(txtNewPassword,"wrap");
		this.add(lblConfirmNewPassword);
		this.add(txtConfirmNewPassword,"wrap");
		this.add(btnCancel);
		this.add(btnChange);
		
		this.btnCancel.addActionListener(controller);
		this.btnChange.addActionListener(controller);

		this.setTitle("Modification du mot de passe");

		this.setSize(375, 175);
		this.setModal(true);
		this.setVisible(true);
    }

	public String getPass() {
		return this.txtConfirmNewPassword.getText();
	}
}
